package v1

import "github.com/gogf/gf/v2/frame/g"

type TableReq struct {
	g.Meta      `path:"/td/stable/post" method:"post" tags:"TD表" sm:"表"`
	LinkId      string `json:"lid" dc:"连接ID"`
	DbName      string `json:"dbName" dc:"库名"`
	SupperTable bool   `json:"supperTable" dc:"是否为超级表"`
}

type TableRes struct {
	Result interface{} `json:"result" dc:"表数据"`
}

type TableDataReq struct {
	g.Meta     `path:"/td/table/data/post" method:"post" tags:"TD表" sm:"表"`
	LinkId     string `json:"lid" dc:"连接ID"`
	DbName     string `json:"dbName" dc:"库名"`
	TableName  string `json:"tableName" dc:"表名"`
	StableName string `json:"stableName" dc:"超级表名"`
	PaginationReq
}

type TableDataQueryReq struct {
	g.Meta `path:"/td/table/query/post" method:"post" tags:"TD表" sm:"表"`
	LinkId string `json:"lid" dc:"连接ID"`
	DbName string `json:"dbName" dc:"库名"`
	Sql    string `json:"sql" dc:"执行语句"`
}

type TableColumnsReq struct {
	g.Meta     `path:"/td/table/columns/post" method:"post" tags:"TD表" sm:"表"`
	LinkId     string `json:"lid" dc:"连接ID"`
	DbName     string `json:"dbName" dc:"库名"`
	TableName  string `json:"tableName" dc:"表名"`
	StableName string `json:"stableName" dc:"超级表名"`
	PaginationReq
}

type TableDelReq struct {
	g.Meta    `path:"/td/table/del/post" method:"post" tags:"TD表" sm:"表"`
	LinkId    string `json:"lid" dc:"连接ID"`
	DbName    string `json:"dbName" dc:"库名"`
	TableName string `json:"tableName" dc:"表名"`
}

type TableDdlReq struct {
	g.Meta    `path:"/td/table/ddl/post" method:"post" tags:"TD表" sm:"表"`
	LinkId    string `json:"lid" dc:"连接ID"`
	DbName    string `json:"dbName" dc:"库名"`
	TableName string `json:"tableName" dc:"表名"`
}

type TableCreateReq struct {
	g.Meta     `path:"/td/table/create/post" method:"post" tags:"TD表" sm:"表"`
	LinkId     string          `json:"lid" dc:"连接ID"`
	DbName     string          `json:"dbName" dc:"库名"`
	TableName  string          `json:"tableName" dc:"表名"`
	IsSupper   bool            `json:"isSupper" dc:"是否为超级表"`
	STableName string          `json:"sTableName" dc:"超级表名"`
	Fields     []TableFiledReq `json:"fields" dc:"字段列"`
}

type TableFiledReq struct {
	FieldName      string `json:"fieldName" dc:"字段名"`
	FieldType      string `json:"fieldType" dc:"数据类型"`
	FieldLen       int    `json:"fieldLen" dc:"长度"`
	FieldAttribute string `json:"fieldAttribute" dc:"属性"`
	Primary        bool   `json:"primary" dc:"是否为主键"`
}

type TableDataRes struct {
	Columns []string            `dc:"列名"`
	Datas   []map[string]string `dc:"数据"`
	PaginationRes
}

type TableExecSqlReq struct {
	g.Meta `path:"/td/table/execSql/post" method:"post" tags:"TD表" sm:"表"`
	LinkId string `json:"lid" dc:"连接ID"`
	DbName string `json:"dbName" dc:"库名"`
	Sql    string `json:"sql" dc:"执行语句"`
}
